package com.example.demo2.service.impl;

import com.example.demo2.dao.TestMapper;
import com.example.demo2.service.ICheckService;
import com.example.demo2.service.ITestCase4NotSupportedService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import static com.example.demo2.utils.HttpUtils.check;

@Slf4j
@Service
public class TestCase4NotSupportedServiceImpl implements ITestCase4NotSupportedService {

    @Autowired
    private TestMapper testMapper;
    @Autowired
    private ICheckService checkService;

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public void insertSomeData() {
        log.info("------------------------------------------------");
        testMapper.insert("case4.3.2");
        check();
        log.info("可以在其他事务中查到 case4.3.2，查不到还没有提交的case4.3.1");
        checkService.check();
        log.info("这里也查不到4.3.1");
    }
}
